<div class="row-fluid">
	<div class="span12">
		<div class="box">
			<div class="box-head">
				<h3>Publish App to Facebook</h3>
			</div>
			<div class="box-content">
                        <?php if(count($_POST) > 0){?>
                        <div class="alert alert-info">
                            Data saved succsesfully
                        </div>
                        <?php } ?>
                            
			<?php if($view->error){?>
			<div class="alert alert-error"><?php echo $view->error;?></div>
			<?php } ?>
				<form action="" class="form-horizontal" method="post">

					<fieldset>
						<!-- <legend>Legend text</legend> -->
						<div class="control-group">
							<label for="basicround" class="control-label">IFrame URL</label>
							<div class="controls">
                                                            <input onclick="this.select();" readonly="readonly" style="width:98%;cursor: text;" type="text" name="data[iframe_url]" id="iframe_url" value="<?php echo $view->iframe_url; ?>" />                                                                
							</div>
						</div>

                                                <div class="control-group">
							<label for="basicround" class="control-label">
                                                            <?php
                                                            if($view->user['fb_page_data'] != "") {
                                                                echo "Published to";
                                                            } else {
                                                                echo "Facebook tab publish";
                                                            }
                                                            ?>

                                                        </label>
							<div class="controls">
                                                            <div class="detailrightformtext">
                                                            <?php
                                                            if($view->user['fb_page_data'] != "") {
                                                            $pagedata = unserialize($view->user['fb_page_data']);
                                                            ?>
                                                                Facebook page:
                                                                <a target="_blank" href="<?php echo $pagedata['link']; ?>?sk=app_<?php echo $view->config['facebook_app_id'];?>">
                                                                <?php echo $pagedata['name']; ?>
                                                                </a>
                                                                <br/>
                                                                Page ID: <?php echo $pagedata['id']; ?>
                                                            <?php } ?>
                                                                <!-- http://www.facebook.com/add.php?api_key=<?php echo $view->config['facebook_app_id'];?>&pages=1&page=<?php echo $pagedata['id']; ?> -->
                                                                <br/><br/>
                                                                <a href="https://www.facebook.com/dialog/pagetab?redirect_uri=<?php echo $view->tab_receive_url;?>&api_key=<?php echo $view->config['facebook_app_id'];?>&app_id=<?php echo $view->config['facebook_app_id'];?>&locale=en_US&sdk=joey&display=popup" class="btn btn-primary" type="button">
                                                                    <?php
                                                                    if($view->user['fb_page_data'] != "") {
                                                                        echo "Change Facebook page";
                                                                    } else {
                                                                        echo "Publish to Facebook page";
                                                                    }
                                                                    ?>
                                                                </a>
                                                                <?php
                                                                    if($view->user['fb_page_data'] != "") {
                                                                ?>
                                                                <br/><br/>
                                                                <a target="_blank" href="https://www.facebook.com/pages/edit/?id=<?php echo $pagedata['id']; ?>&sk=apps" class="btn btn-danger tip"  data-placement="right" data-original-title="You need to have Administrator access to the Facebook page to do this" type="button">
                                                                    Remove app from Facebook page
                                                                </a>
                                                                <?php
                                                                    }
                                                                ?>

                                                            </div>


							</div>
                                                    <div class="control-group">
                                                        <label class="control-label">Embedded code</label>
                                                        <div class="controls">                                                            
                                                            <textarea readonly="readonly" style="width:100%;cursor: text;" onclick="this.select();" name="iframe" class="input-square span9" rows="6"><iframe src="<?php echo $view->iframe_url; ?>" frameborder=0 style="border-width:0px;" height="<?php echo $view->frontendsetup['facebook_tab_height'];?>" width="810" scrolling=no></iframe></textarea>
                                                        </div>
                                                    </div>
						</div>
					</fieldset>
				</form>
			</div>
		</div>
	</div>
</div>
